package cn.wolfcode.wechat.domain;

import com.alibaba.fastjson.JSON;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.math.BigDecimal;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

/**
 * 用户充值
 */
@Setter@Getter
public class Recharge {
    public static final int STATE_NORMAL = 0;//待审核
    public static final int STATE_PASS = 1;//审核通过
    public static final int STATE_REJECT = 2;//审核拒绝

    private Long id;
    protected int state;//审核状态
    private BigDecimal amount;
    private String bank;
    private String remark;
    private String note;
    private String tradeCode;
    private Client client;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date auditTime;

    public String getStateDisplay(){
        switch (this.state){
            case STATE_NORMAL : return "待审核";
            case STATE_PASS : return "审核通过";
            case STATE_REJECT : return "审核拒绝";
            default: return "";
        }
    }
    public String getJsonString(){
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", id);
        map.put("username", client.getNickname());
        map.put("tradeCode", tradeCode);
        map.put("amount", amount);
        //map.put("tradeTime", new SimpleDateFormat("yyyy-MM-dd").format(tradeTime));
        return JSON.toJSONString(map);
    }
}
